import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;

import java.io.IOException;
@WebServlet("/servletC")
public class ServletC extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        String username = req.getParameter("username");
        HttpSession session = req.getSession();
        //时间 秒数
        session.setMaxInactiveInterval(60*30);
        System.out.println(session.getId());
        System.out.println(session.isNew());
        session.setAttribute("username", username);
        resp.getWriter().write("OK");

    }
}
